<template>
  <j-modal title="预约信息" :width="800" :visible="visible" switchFullscreen @cancel="handleCancel" @ok="handleOk">
    <div>
      <p>人员类型：{{ setTittle(infoObj.type) }}</p>
      <p>被谈话人：{{ infoObj.name }}</p>
      <p>访谈类型： 帮教谈心 </p>
      <p>访谈次数：第 {{ interviewNum }} 次</p>
      <p>访谈分类：{{ infoObj.converConClassification }}</p>
      <p>访谈主题：{{ infoObj.topic }}</p>
      <p>预约时间：{{ infoObj.talkTime }}</p>
      <p>谈话地点：{{ infoObj.placeConConversation }}{{ infoObj.detailConAddress }}</p>
    </div>
    <a-tabs default-active-key="1" @change="onTabChange">
      <a-tab-pane key="1" tab="访谈大纲">
        <p class="p1">一、基础面</p>
        <div v-for="item in infoObj.base" :key="item.problem">
          <p>{{ item.problem }}</p>
          <p>{{ item.answer }}</p>
        </div>
        <p class="p1">二、分析面</p>
        <div v-for="item in infoObj.analyze" :key="item.problem">
          <p>{{ item.problem }}</p>
          <p>{{ item.answer }}</p>
        </div>
        <p class="p1">三、拓展面</p>
        <div v-for="item in infoObj.expand" :key="item.problem">
          <p>{{ item.problem }}</p>
          <p>{{ item.answer }}</p>
        </div>
      </a-tab-pane>
    </a-tabs>
    <p class="p1">访谈材料</p>
    <j-upload v-model="infoObj.applyFile" :number="1"></j-upload>
    <template slot="footer">
      <p style="text-align: left;">创建人：{{ infoObj.createBy }} <span style="margin-left:30px;">创建时间：{{
    infoObj.createTime
          }}</span> </p>
    </template>
  </j-modal>
</template>
<script>
import * as educationTalk from '@/api/sjsk/help/educationTalk.js'
export default {
  name: 'detailModal',
  data() {
    return {
      visible: false,
      infoObj: {},
      interviewNum: 0
    }
  },
  async created() {
  },
  methods: {
    show(record) {
      this.visible = true
      this.infoObj = {}
      this.interviewNum = record.interviewNum //统一从列表拿次数
      this.getDetail(record)
    },
    getDetail(record) {
      let type = ""
      if (record.personId) {
        type = "1" //sjsk
      } else {
        type = "2" //社会面
      }
      educationTalk.intHistoryDetails({ id: record.id, type: type, status: record.status }).then((res) => {
        if (res.success) {
          if (res.result != null) {
            this.infoObj = res.result ? res.result : {}
            this.infoObj.personId = Number(res.result.personId) //色戒社康人员id是整型，要转换同类型才显示名字

            //基础面
            let arr11 = res.result.surfaceContent.split(';') //问题
            let arr12 = res.result.surfaceAnswer.split(';') //答案
            let arrtotal1 = []
            arr11.forEach((item, index) => {
              arrtotal1.push({ problem: item, answer: arr12[index] })
            });
            this.infoObj.base = arrtotal1
            //分析面
            let arr21 = res.result.analyticalContent.split(';') //问题
            let arr22 = res.result.analyticalAnswer.split(';') //答案
            let arrtotal2 = []
            arr21.forEach((item, index) => {
              arrtotal2.push({ problem: item, answer: arr22[index] })
            });
            this.infoObj.analyze = arrtotal2
            //拓展面
            let arr31 = res.result.expansionContent.split(';') //问题
            let arr32 = res.result.expansionAnswer.split(';') //答案
            let arrtotal3 = []
            arr31.forEach((item, index) => {
              arrtotal3.push({ problem: item, answer: arr32[index] })
            });
            this.infoObj.expand = arrtotal3
          }
        }
      })
    },
    setTittle(text) {
      return this.$filterDictTextByCache('personType', text)  //现在字典中对应的文字，是全局函数
    },
    onTabChange() {

    },
    handleCancel() {
      this.visible = false
    },
    handleOk() {
      this.visible = false
    }
  },
}
</script>
<style lang="less" scoped>
/deep/ .ant-modal-footer {
  display: flex;
  justify-content: space-between;
}

/deep/.ant-upload {
  display: none;
}

.p1 {
  font-weight: bold;
}
</style>
